﻿@model LeadMaster.ViewModels.ViewModelCompanies

<table class="listtable contactstable" cellspacing="0" cellpadding="0" style="width: 1050px;">
<thead>
<tr>
<th>Description</th>
<th>Lead Question</th>
<th>Mandatory Lead Question</th>
<th>Can Repair</th>
<th>Can Replace</th>
<th></th>
</tr>
</thead>
@{
    if (Model.ListCompanyRegistered !=null && Model.ListCompanyRegistered.Count>0)
	{
        foreach (var item in Model.ListCompanyRegistered)
        {
            <tr>
                <td><label class="selectregistration" data-registrationid="@(item.CompanyRegisteredID)" style="cursor: pointer; color: #333333;">@item.Description</label></td>
                <td><label>@item.LeadQuestion</label></td>
                <td><label>@item.MandatoryLeadQuestion</label></td>
                <td><label>@item.CanRepair</label></td>
                <td><label>@item.CanReplace</label></td>
                <td><img src="~/Images/delete.ico" style="width: 20px; height: 20px" class="deleteregistration" data-registration="@(item.CompanyRegisteredID)"/></td>
            </tr>
        }
    }
}
</table>

<input type="button" value="Add" id="addRegistration"/>

<div id="newreg">
</div>

<script type="text/javascript">
$().ready(function () {

    $("#newreg").dialog(
        {
            autoOpen: false,
            width: 900,
            open: function () { $(".ui-dialog").css("box-shadow", "#000 5px 5px 5px"); },
            position: ['middle', 20],
            modal: true,
            dialogClass: 'notitle',
            buttons: {
                save: function () {
                    $(this).dialog("close");
                    $("#formCompanyRegistration").submit();
                },
                cancel: function () {
                    $(this).dialog("close");
                }
            }
        });
    
        $("#addRegistration").click(function() {
            $('#newreg').dialog("open");
            $('#newreg').html('<div style="text-align: center;"><div><img src="@Url.Content("~/Images/ajaxspinner_large.gif")" alt="Loading..." style="margin: 20px;" /></div><div>Loading...</div></div>');
            var contactURL='@(Url.Action("NewCompanyRegistration", "Leads"))/?CompanyID=' + @(ViewBag.CompanyID);
            $('#newreg').load(contactURL);
        });

        $(".deleteregistration").click(function () {
            var ans=confirm("Are you sure you wish to delete this registration ?")
            if (ans==true) {
                var contactURL = '@(Url.Action("DeleteRegistration", "Leads"))/?id=' + $(this).data("registration");
                $('#companyregistrations').load(contactURL);
            }
        });

        $(".selectregistration").click(function () {
            $("#newreg").dialog("open");
            $('#newreg').html('<div style="text-align: center;"><div><img src="@Url.Content("~/Images/ajaxspinner_large.gif")" alt="Loading..." style="margin: 20px;" /></div><div>Loading...</div></div>');
            var contactURL = '@(Url.Action("EditRegistration", "Leads"))/?id=' + $(this).data("registrationid");
            $('#newreg').load(contactURL);
        });

});
</script>